//轮播
let rongQi = document.querySelector('#rong-qi');
let lunBo = document.querySelector('#lun-bo');
let lunBoChangDu = document.querySelectorAll(".tu").length;
let lunBoSuo = true;

function zuoYiDong() {
	if (lunBoSuo) {
		lunBoSuo = false;
		setTimeout(() => {
			lunBoSuo = true;
		}, 500)
		let tu = document.querySelectorAll(".tu");
		tu[0].className = 'tu';
		tu[0].onclick = null;
		tu[1].className = 'tu tu-zuo';
		tu[1].onclick = zuoYiDong;
		tu[2].className = 'tu tu-zhong';
		tu[2].onclick = null;
		tu[3].className = 'tu tu-you';
		tu[3].onclick = youYiDong;
		lunBo.appendChild(tu[0]);
	}
}
zuoYiDong()
function youYiDong() {
	if (lunBoSuo) {
		lunBoSuo = false;
		setTimeout(() => {
			lunBoSuo = true;
		}, 500)
		let tu = document.querySelectorAll(".tu");
		lunBo.insertBefore(tu[lunBoChangDu - 1], lunBo.firstChild);
		tu = document.querySelectorAll(".tu");
		tu[0].className = 'tu tu-zuo';
		tu[0].onclick = zuoYiDong;
		tu[1].className = 'tu tu-zhong';
		tu[1].onclick = null;
		tu[2].className = 'tu tu-you';
		tu[2].onclick = youYiDong;
		tu[3].className = 'tu';
		tu[3].onclick = null;
	}
}
youYiDong()
let carouselInterval = setInterval(() => {
	youYiDong()
}, 3000)
rongQi.addEventListener('mouseover', () => {
	clearInterval(carouselInterval)
})
rongQi.addEventListener('mouseleave', () => {
	carouselInterval = setInterval(() => {
		youYiDong()
	}, 3000)
})
